<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <title>打包记录 - {$tp_config.shop_info_store_name}</title>
        <link rel="stylesheet" href="__STATIC__/index/css/font.css">
        <link rel="stylesheet" href="__STATIC__/index/layui/css/layui.css?t=1527238724161">
        <link rel="stylesheet" href="__STATIC__/index/css/global.css" charset="utf-8">
    </head>
    <style type="text/css" media="screen">
        .demo-class{
            color: red;
        }
    </style>
    <body>
        <include file="public/header"/>
        <div class="layui-container fly-marginTop fly-user-main">
            <include file="public/left"/>
            <div class="fly-panel fly-panel-user" pad20>
                <div class="layui-tab layui-tab-brief" lay-filter="pack">
                    <ul class="layui-tab-title">
                        <li lay-id="{:url('Pack/packList')}">面单列表</li>
                        <!-- <li lay-id="{:url('Pack/goodsList')}">商品列表</li> -->
                        <li class="layui-this" lay-id="{:url('Pack/packAdd')}">新增打包</li>
                    </ul>
                    <div class="layui-tab-content" style="padding: 20px 0;">
                        <div class="layui-form layui-form-pane layui-tab-item layui-show">
                            <form method="post" id="L_goods_pack_info">
                                <blockquote class="layui-elem-quote">基本信息
                                        <a href="javascript:;" style="color: #4f99cf;float: right;"  id="L_company_code">查看快递公司编码</a>
                                </blockquote>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">平台</label>
                                    <div class="layui-input-inline">
                                        <select name="platform_code" lay-verify="reque" lay-filter="platform_code" required="" id="oyhfd">
                                          <foreach name="platform" item="v">
                                          <option value="{$key}" <if condition="$info.platform_code eq $key">selected</if> data-price="{$v.free}">{$v.name}</option>
                                          </foreach>
                                        </select> 
                                    </div>
                                    <div class="layui-form-mid layui-word-aux" id="free-info"></div>
                                </div>
                                
                                <div class="layui-form-item">
                                    <label for="L_email" class="layui-form-label">面单编号</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="pack_number" value="{$info.pack_number}" required="" lay-verify="pack_number" autocomplete="off" value="" class="layui-input" placeholder="请填写面单条码下方编号" onKeyUp="value=value.replace(/[\W]/g,'')">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label for="L_email" class="layui-form-label">面单文件</label>
                                    <div class="layui-input-inline">
                                        <input type="radio" name="filter" value="1" title="上传" checked lay-filter="isfile">
                                        <input type="radio" name="filter" value="0" title="链接" lay-filter="isfile">
                                    </div>
                                    <div class="layui-input-inline" style="min-width: 150px">
                                        <button type="button" class="layui-btn" id="L_upload_pdf">
                                          <i class="layui-icon">&#xe67c;</i>面单PDF文件
                                        </button>
                                         <input type="text" name="pack_file" value="{$info.pack_file}" required="" class="layui-hide layui-input">
                                    </div>
                                   

                                    
                                   
                                    
                                    <div class="layui-form-mid layui-word-aux">
                                        <a href="javascript:;" target="_blank" id="L_show" class="<if condition='empty($info.pack_file)'>layui-hide</if>" style="color:#4f99cf">查看</a>
                                    </div>
                                    
                                </div>
                                <if condition="$info.goodsList">
                                <foreach name="$info.goodsList" item="vo">
                                <div class="layui-form-item goods-info-item">
                                    <label for="L_email" class="layui-form-label">商品信息</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="goods_name[]" value="{$vo.goods_name}" required="" lay-verify="goods_name" autocomplete="off" value="" class="layui-input" placeholder="商品标题">
                                    </div>
                                    <div class="layui-input-inline" style="max-width: 80px">
                                        <input type="text" name="goods_num[]" value="{$vo.goods_num}" required="" lay-verify="goods_num" autocomplete="off" value="" class="layui-input" placeholder="数量" onkeyup="this.value=this.value.replace(/\D/g,'')"> 
                                    </div>
                                    <div class="layui-input-inline">
                                        <input type="text" name="goods_origin[]" value="{$vo.goods_origin}" required="" lay-verify="goods_origin" autocomplete="off" value="" class="layui-input" placeholder="商品图片URL地址" blur="checkImageUrl()"> 
                                    </div>
                                    <div class="layui-input-inline" style="max-width: 100px">
                                        <select name="express_code[]" lay-verify="express_code" required="">
                                          <option value="">物流公司</option>
                                          <foreach name="Express" item="v">
                                          <option value="{$key}" <if condition="$vo.express_code eq $key">selected</if>>{$v}</option>
                                          </foreach>
                                        </select> 
                                    </div>
                                    <div class="layui-input-inline" style="max-width: 150px">
                                        <input type="text" name="express_number[]" value="{$vo.express_number}" required="" lay-verify="express_number" autocomplete="off" value="" class="layui-input" placeholder="快递单号" onKeyUp="value=value.replace(/[\W]/g,'')"> 
                                    </div>
                                    <if condition="$key neq 0">
                                        <div class="layui-form-mid layui-word-aux">
                                            <i class="layui-icon layui-icon-close remove-goods-row" style="color:#FF5722;font-size: 24px;"></i>   
                                        </div>
                                    </if>
                                </div>
                                </foreach>
                                <else/>
                                <div class="layui-form-item goods-info-item">
                                    <label for="L_email" class="layui-form-label">商品信息</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="goods_name[]" value="" required="" lay-verify="goods_name" autocomplete="off" value="" class="layui-input" placeholder="商品标题">
                                    </div>
                                    <div class="layui-input-inline" style="max-width: 80px">
                                        <input type="text" name="goods_num[]" value="" required="" lay-verify="goods_num" autocomplete="off" value="" class="layui-input" placeholder="数量" onkeyup="this.value=this.value.replace(/\D/g,'')"> 
                                    </div>
                                    <div class="layui-input-inline">
                                        <input type="text" name="goods_origin[]" value="" required="" lay-verify="goods_origin" autocomplete="off" value="" class="layui-input" placeholder="商品图片URL地址" blur="checkImageUrl()"> 
                                    </div>
                                    <div class="layui-input-inline" style="max-width: 100px">
                                        <select name="express_code[]" lay-verify="express_code" required="">
                                          <option value="">物流公司</option>
                                          <foreach name="Express" item="vo">
                                          <option value="{$key}">{$vo}</option>
                                          </foreach>
                                        </select> 
                                    </div>
                                    <div class="layui-input-inline" style="max-width: 150px">
                                        <input type="text" name="express_number[]" value="" required="" lay-verify="express_number" autocomplete="off" value="" class="layui-input checkShipping" placeholder="快递单号" onKeyUp="value=value.replace(/[\W]/g,'')"> 
                                    </div>
                                </div>
                                </if>

                                <div class="layui-form-item" style="text-align: center;"> 
                                    <p style="color: #d2d2d2">添加商品</p>
                                    <i class="layui-icon layui-icon-add-circle" style="color:#5FB878;font-size: 24px;" id="L_add_goods_row"></i>      
                                </div>



                                <div class="layui-form-item layui-form-text">
                                    <label for="L_sign" class="layui-form-label">我们需要注意什么</label>
                                    <div class="layui-input-block">
                                        <textarea placeholder="例如：商品尺码，颜色，件数，其他···" id="L_pack_note" name="pack_note" autocomplete="off" required="" class="layui-textarea" style="height: 80px;">{$info.pack_note}</textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    {:token()}
                                    <button class="layui-btn" key="set-mine" lay-filter="goods" lay-submit="">确认提交</button>
                                    <a class="layui-btn" id="help">帮助</a>
                                </div>
                            </form>
                        </div>
                        <div style="padding: 25px">
                            <fieldset class="layui-elem-field layui-field-title">
                                <legend style="color:#FF5722;">温馨提示</legend>
                                <div class="layui-field-box" style="color: #FF5722">
                                    <p>亲爱的客户朋友们，发货物流包裹收件地址 后面请记得填写您的姓名+本平台帐号(注册手机号)。</p>
                                    <p>例如：深圳市宝安区福永街道凤塘大道612_6 杨生 15826332989</p>
                                </div>
                            </fieldset>
                        </div>
                        <div id="helpHtml" style="display: none;">
                            <div class="layui-collapse" lay-filter="test">
                              <div class="layui-colla-item">
                                <h2 class="layui-colla-title">提示面单已存在？</h2>
                                <div class="layui-colla-content">
                                  <p>如果系统提示面单已经存在，先检查自己面单中是否存在相同面单号面单，如果面单未支付，则自己可以手动取消面单，其他情况则联系管理员处理。</p>
                                </div>
                              </div>
                            </div>
                        </div>
                
                    </div>
                </div>
            </div>
        </div>
        <include file="public/footer">
        <script src="__STATIC__/index/js/user.js"></script>
        <script>
        layui.define(['element','upload','form'], function(exports){

            var $ = layui.jquery;
            var upload = layui.upload;
            var form = layui.form;
            var layer = layui.layer;

            var AJAXUPLOADURL = '{:url("api/upload")}';
            showPrice();

            //执行实例
              var uploadInst = upload.render({
                elem: '#L_upload_pdf' //绑定元素
                ,url: AJAXUPLOADURL //上传接口
                ,done: function(res){
                   if (res.status==1) {
                        $('#L_show').attr('href',res.result.url).removeClass('layui-hide');
                        $('input[name=pack_file]').val(res.result.url);
                   }
                }
                ,error: function(){
                  layui.open({
                    type:1
                    ,contet:"失败"
                  });
                }
                ,accepts: 'file'
                ,exts:'pdf'
                ,size: 500 //最大允许上传的文件大小 500kb
              });


            $(".checkShipping").blur(function(){
                var type = $(this).parent().prev().find('select').val()
                ,code = $(this).val();
                if (type=='') {
                    layer.msg('请填选择物流公司', {icon: 5});return false;
                }
                if (code=='') {
                    layer.msg('请填写快递单号', {icon: 5});return false;
                }

                $.post('{:url("api/checkShipping")}', {type:type,code:code}, function(data, textStatus, xhr) {
                    if (data.Success) {
                        // layer.tips('物流正常', '.checkShipping');
                        layer.msg('物流正常', {icon: 6});
                    }else{
                        // layer.tips('请填写有效的快递单号', '.checkShipping');
                        layer.msg('请填写有效的快递单号', {icon: 5});
                    }
                     
                },'json');

            });

             //查看帮助
            $("#help").on('click', function(event) {
                 layer.open({
                    type:1
                    ,title:'帮助'
                    ,area: ['450px', '300px']
                    ,content: $('#helpHtml')
                  });
            });

            //外贸平台选中事件
            form.on('select(platform_code)', function(data){
                var price = $(data.elem).find("option:selected").data("price"); //得到select原始DOM对象
                $('#free-info').text(price+'元/单');
            });  

            function showPrice() {
                
                $('#free-info').text($('#oyhfd').find("option:selected").data("price")+'元/单');
              }  

            form.on('radio(isfile)', function(data){
              // console.log(data.elem); //得到radio原始DOM对象
              console.log(data.value); //被点击的radio的value值
              if (data.value==1) {
                    $('#L_upload_pdf').removeClass('layui-hide');
                    $('input[name=pack_file]').addClass('layui-hide');
              }else{
                    $('#L_upload_pdf').addClass('layui-hide');
                    $('input[name=pack_file]').removeClass('layui-hide');
              }
            });  
        });
        </script>
    </body>
</html>
